package com.ihd.ihardware.view.tzc.discovery.view;

import android.os.Bundle;

import com.ihd.ihardware.R;
import com.ihd.ihardware.common.AppConstans;
import com.ihd.ihardware.databinding.ActivityCategoryBinding;
import com.ihd.ihardware.pojo.ArticalRes;
import com.ihd.ihardware.view.tzc.discovery.viewmodel.CategoryViewModel;

import cn.wowjoy.commonlibrary.base.BaseActivity;
import cn.wowjoy.commonlibrary.base.BaseConsumer;

public class CategoryActivity extends BaseActivity<ActivityCategoryBinding, CategoryViewModel> {

    private String title;
    private String id;

    @Override
    protected void init(Bundle savedInstanceState) {
        mImmersionBar.statusBarDarkFont(true).init();
        binding.mtitlebar.setTitle("分类-秘籍");
        binding.mtitlebar.setLeftBack(this);

        title = getIntent().getStringExtra("arts");
        id = getIntent().getStringExtra("artsId");

        binding.categoryTV.setText(title);

        setRx(AppConstans.ARTS_SUB, new BaseConsumer<ArticalRes>() {
            @Override
            protected void onStart() {
            }

            @Override
            protected void onSuccess(ArticalRes mLiveData) {
                viewModel.setCollectList(mLiveData.getData().getList());
            }

            @Override
            protected void onError(Throwable error) {
            }
        });

        binding.artsRV.setAdapter(viewModel.mCollectAdapter);
        viewModel.getCollectList(1, 100, id);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_category;
    }

    @Override
    protected Class getViewModelClass() {
        return CategoryViewModel.class;
    }

}
